package main

import (
	"fmt"
	"os"
	"strconv"
)

type u struct {
	name           string
	date           string
	days           string
	photo_nums     string
	fee            string
	people         string
	fee_int        int
	photo_nums_int int
	id             int
	err            error
}

func query() {
	a := make(map[int]int)
	rows, err := db.Query("select name,date,days,photo_nums,fee,people from data where fee!=0")
	if err != nil {
		panic(err)

	}
	defer rows.Close()
	for rows.Next() {
		user := u{}
		err := rows.Scan(&user.name, &user.date, &user.days, &user.photo_nums_int, &user.fee_int, &user.people)
		if err != nil {
			panic(err)
		}
		a[user.fee_int]++
	}
	file, _ := os.OpenFile("D:\\t1.txt", os.O_APPEND|os.O_CREATE, 0666)
	file2, _ := os.OpenFile("D:\\t2.txt", os.O_APPEND|os.O_CREATE, 0666)
	for i, i2 := range a {
		fmt.Println(i, i2)
		file.WriteString(strconv.Itoa(i) + "\n")
		file2.WriteString(strconv.Itoa(i2) + "\n")
	}
}
